package cn.puge.mertisfront.controller;


import cn.puge.commonutils.R;
import cn.puge.mertisfront.entity.PugeMeet;
import cn.puge.mertisfront.service.PugeMeetService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *  会议记录
 * @author LIJW
 * @since 2020-09-18
 */
@RestController
@RequestMapping("/mertisfront/puge-meet")
@CrossOrigin
public class PugeMeetController {

    @Autowired
    private PugeMeetService pugeMeetService;

    /**
     * 分页获取所有会议记录
     * @return
     */
    @GetMapping("getAllMeet/{page}/{limit}")
    public R getAllMeet(@PathVariable long page,
                        @PathVariable long limit){

        Page<PugeMeet> pugeMeetPage = new Page<>(page,limit);
        QueryWrapper<PugeMeet> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("gmt_create");
        pugeMeetService.page(pugeMeetPage,queryWrapper);
        return R.ok().data("total",pugeMeetPage.getTotal()).data("pugeMeeta",pugeMeetPage.getRecords());
    }

}

